跪拜 ASP问题 急`````

来源:百度知道 编辑:UC知道 时间:2024/06/21 18:24:39
Function GetPage(url)
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False ', "", ""
.Send
body = BytesToBstr(.ResponseBody)
Response.Write body
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function

Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

谁能帮我把代码注释写出来(越详细越好,每句都要!谢谢啦)

Function GetPage(url) '定义个函数,名字GetPage,参数url
dim Retrieval '定义变量
Set Retrieval = CreateObject("Microsoft.XMLHTTP") '创建一个xmlhttp对象,并将对象赋值给Retrieval变量
With Retrieval '设置操作范围,直到遇见end with,下面每句代码前都默认添加Retrieval
.Open "Get", url, False ', "", "" '打开一个URL地址(相当于Retrieval.Open ...)
.Send '发送xmlhttp请求(相当于Retrieval.Send)
body = BytesToBstr(.ResponseBody) '将http请求返回的字符串处理后赋值给body变量
Response.Write body '输出body变量到页面
GetPage = BytesToBstr(.ResponseBody) '设置函数返回值(实际上返回内容跟body变量一样)
End With '结束操作范围,同上面的With Retrieval对应
Set Retrieval = Nothing '释放xmlhttp对象
End Function '函数定义完毕

Function BytesToBstr(body) '定义一个函数,此函数在上面的函数中被调用到
dim objstream '声明变量
set objstream = Server.CreateObject("adodb.stream") '创建stream对象并赋值给objsteam,该对象主要应用于数据流输出和控制
objstream.Type = 1 '设置objstream数据类型为字节
objstream.Mode =3 '设